/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Andre
 */
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@Table(name = "fornecedor")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Fornecedor.findAll", query = "SELECT f FROM Fornecedor f"),
    @NamedQuery(name = "Fornecedor.findByDataInclusao", query = "SELECT f FROM Fornecedor f WHERE f.dataInclusao = :dataInclusao"),
    @NamedQuery(name = "Fornecedor.findByRazaoSocial", query = "SELECT f FROM Fornecedor f WHERE f.razaoSocial = :razaoSocial")})
public class Fornecedor extends Pessoa implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "dataInclusao")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataInclusao;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 80)
    @Column(name = "razaoSocial")
    private String razaoSocial;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fornecedor")
    private List<Compra> compraList;

    public Fornecedor() {
    }

    public Fornecedor(Date dataInclusao, String razaoSocial) {
        this.dataInclusao = dataInclusao;
        this.razaoSocial = razaoSocial;
    }
    
    public Fornecedor(String nome, String cgc, String tipoPessoa, Date dataInclusao, String razaoSocial){
        super(nome, cgc, tipoPessoa);
        this.dataInclusao = dataInclusao;
        this.razaoSocial  = razaoSocial;
    }

    public Date getDataInclusao() {
        return dataInclusao;
    }

    public void setDataInclusao(Date dataInclusao) {
        this.dataInclusao = dataInclusao;
    }

    public String getRazaoSocial() {
        return razaoSocial;
    }

    public void setRazaoSocial(String razaoSocial) {
        this.razaoSocial = razaoSocial;
    }
    
    @XmlTransient
    public List<Compra> getCompraList() {
        return compraList;
    }

    public void setCompraList(List<Compra> compraList) {
        this.compraList = compraList;
    }
    
}
